<link type="text/css" href="<?= base_url() ?>css/jquery.jcarousel.skin.css" rel="stylesheet" /> 
<link type="text/css" href="<?= base_url() ?>css/jquery.jcarousel.skin.slideshow.css" rel="stylesheet" /> 
<script type="text/javascript" src="<?= base_url() ?>js/jquery.jcarousel.min.js"></script>
<? $address = $listing->address_street_no . ' ' . $listing->address_street . ' ' . $listing->address_street_type . ' ' . $listing->address_suburb . ' ' . $listing->address_postcode ?>
<script>
    var map;
    var lat;
    var lng;
    var mapOptions;
    var geocoder;
    var address;
    var myLatlng;
	
    $(document).ready(function() {
	    	
        $(".property .contentright").height($(".property .contentleft").height());
	    	
        geocoder = new google.maps.Geocoder();
        geocoder.geocode({'address': '<?= $address ?>'}, function(results, status) {
            if (status==google.maps.GeocoderStatus.OK) {
                myLatlng = results[0].geometry.location;
                mapOptions = {
                    center: myLatlng,
                    zoom: 15,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);
                var marker = new google.maps.Marker({
                    position: myLatlng,
                    title:address
                });
                marker.setMap(map);
            }
            else {
                geocoder.geocode({'address': 'Australia'}, function(results, status) {
                    if (status==google.maps.GeocoderStatus.OK) {
                        myLatlng = results[0].geometry.location;
                        mapOptions = {
                            center: myLatlng,
                            zoom: 15,
                            mapTypeId: google.maps.MapTypeId.ROADMAP
                        };
                        map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);
                        var marker = new google.maps.Marker({
                            position: myLatlng,
                            title:address
                        });
                        marker.setMap(map);
                    }
                    else {
                        alert('Address not found');
                    }
                });
            }
        });
	    	
    });
    
    function validateEmail($email) {
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
        if( !emailReg.test( $email ) ) {
            return false;
        } else {
            return true;
        }
    }
    
    function printContent(){
       window.print();
        return true;
    }
    

</script>

<div class="content general-content property" id="page-body">
    <div class="contentleft">
        <!-- Property Address -->
        <div class="address"><h1><?= ucwords($listing->address_street_no . ' ' . $listing->address_street . ' ' . $listing->address_street_type . ' ' . $listing->address_suburb . ' ' . $listing->address_postcode) ?></h1></div>

        <!-- Price and Main Features -->
        <div>
            <div class="price">
                <?
                $price = $listing->display_price;
                if ($price == '' && $listing->price_min != $listing->price_max)
                    $price = '$' . $listing->price_min . ' to $' . $listing->price_max;
                else if ($price == '' && $listing->price_min == $listing->price_max)
                    $price = '$' . $listing->price_min;
                ?>
                <h3><?= $price ?></h3>
            </div>
            <div class="main-feature">
                <img src="<?= base_url() ?>img/property-landsize-icon.png"/>
                <div><?= $listing->land_size ?><?= $listing->land_size_type ?></div>
            </div>
            <div class="main-feature">
                <img src="<?= base_url() ?>img/property-carparks-icon.png"/>
                <div><?= $listing->carparks ?></div>
            </div>
            <div class="main-feature">
                <img src="<?= base_url() ?>img/property-bathrooms-icon.png"/>
                <div><?= $listing->bathrooms ?></div>
            </div>
            <div class="main-feature">
                <img src="<?= base_url() ?>img/property-bedrooms-icon.png"/>
                <div><?= $listing->bedrooms ?></div>
            </div>
        </div>

        <!-- Photo's and other images -->
        <div class="property-images">
            <?
            $showDefalutimage = true;
            if (isset($listing->property_images)) {
                if (count($listing->property_images) > 0) {
                    $showDefalutimage = false;
                }
            }
            ?>   
            <div style="float:left">
                <div class="main">
                    <img id="property-main-img"  src="<?= (isset($listing->property_images) && count($listing->property_images) > 0 ) ? $listing->property_images[0]->image_url : base_url() . 'img/noimage.png' ?>" />
                </div>
            </div>
            <div style="float:right">
                <div>
                    <ul id="image-carousel" class="jcarousel-skin-tango">
                        <? if ($showDefalutimage == false): ?>    
                            <? foreach ($listing->property_images as $img): ?>
                                <li><img src="<?= $img->image_url ?>" width="100" height="75" alt="" /></li>                                                
                            <? endforeach; ?>
                        <? endif; ?>
                        <? if ($showDefalutimage == true): ?> 
                            <li><img src="<?= base_url() ?>img/noimage.png" width="100" height="75"  alt="" /></li>
                            <li><img src="<?= base_url() ?>img/noimage.png" width="100" height="75"  alt="" /></li>
                            <li><img src="<?= base_url() ?>img/noimage.png" width="100" height="75"  alt="" /></li>
                            <li><img src="<?= base_url() ?>img/noimage.png" width="100" height="75"  alt="" /></li>
                            <li><img src="<?= base_url() ?>img/noimage.png" width="100" height="75"  alt="" /></li>                          
                        <? endif; ?>  

                    </ul>
                    <script type="text/javascript">
						
                        jQuery(document).ready(function() {
                            jQuery('#image-carousel').jcarousel({
                                vertical: true,
                                scroll: 4
                            });
						                
                            jQuery('#image-carousel img').click(function() {
                                $("#property-main-img").attr("src", $(this).attr("src"));
                            });
                        });
						
                    </script>
                </div>
            </div>
        </div>

        <!-- Slideshow -->
        <div class="slideshow">
            <a href="" onclick="$('#slideshow-dialog-modal').dialog('open'); return false;" title="View slideshow" >
                <img src="<?= base_url() ?>img/property-slideshow-icon.png" alt="" title="View slideshow" />
                <span>SLIDESHOW</span>
            </a>
        </div>

        <!-- Feature-line and Description -->
        <div>
            <h3><?= $listing->headline ?></h3>
            <p><?= $listing->description ?></p>
        </div>

        <!-- Features -->
        <div class="features">
            <h3>Features</h3>
            <ul>
                <?= ($listing->exterior_type != '') ? '<li>exterior type: ' . $listing->exterior_type . '</li>' : '' ?>
                <?= ($listing->roofing_type != '') ? '<li>roofing type: ' . $listing->roofing_type . '</li>' : '' ?>
                <?= ($listing->building_size != '0.0000' && $listing->building_size !='') ? '<li>building size: ' . $listing->building_size . ' ' . $listing->building_size_type . '</li>' : '' ?>
                <?= ($listing->year_built != '0000' && $listing->year_built!='') ? '<li>year built: ' . $listing->year_built . '</li>' : '' ?>

                <?= ($listing->land_crossover != '') ? '<li>land crossover: ' . $listing->land_crossover . '</li>' : '' ?>
                <?= ($listing->land_frontage != '0.0000' && $listing->land_frontage != null ) ? '<li>land frontage: ' . $listing->land_frontage . ' ' . $listing->land_frontage_unit . '</li>' : '' ?>
                <?= ($listing->land_depth != '0.0000' && $listing->land_depth != null ) ? '<li>land depth: ' . $listing->land_depth . ' ' . $listing->land_depth_unit . '</li>' : '' ?>
                <?= ($listing->land_depthleft != '0.0000' && $listing->land_depthleft != null ) ? '<li>land depth left: ' . $listing->land_depthleft . ' ' . $listing->land_depthleft_unit . '</li>' : '' ?>
                <?= ($listing->land_depthright != '0.0000' && $listing->land_depthright != null ) ? '<li>land depth right: ' . $listing->land_depthright . ' ' . $listing->land_depthright_unit . '</li>' : '' ?>
                <?= ($listing->land_depthrear != '0.0000' && $listing->land_depthrear != null ) ? '<li>land depth rear: ' . $listing->land_depthrear . ' ' . $listing->land_depthrear_unit . '</li>' : '' ?>

                <?= ($listing->allowances_pet_friendly != 0) ? '<li>allowances pet friendly</li>' : '' ?>
                <?= ($listing->allowances_smoker != 0) ? '<li>allowances smoker</li>' : '' ?>
                <?= ($listing->allowances_furnished != 0) ? '<li>allowances furnished</li>' : '' ?>
                <?= ($listing->study != 0) ? '<li>study</li>' : '' ?>
                <?= ($listing->dishwasher != 0) ? '<li>dishwasher</li>' : '' ?>
                <?= ($listing->built_in_robes != 0) ? '<li>built in robes</li>' : '' ?>
                <?= ($listing->gym != 0) ? '<li>gym</li>' : '' ?>
                <?= ($listing->workshop != 0) ? '<li>study</li>' : '' ?>
                <?= ($listing->study != 0) ? '<li>workshop</li>' : '' ?>
                <?= ($listing->rumpus_room != 0) ? '<li>rumpus room</li>' : '' ?>
                <?= ($listing->floorboards != 0) ? '<li>floorboards</li>' : '' ?>
                <?= ($listing->broadband != 0) ? '<li>broadband</li>' : '' ?>
                <?= ($listing->pay_tv != 0) ? '<li>pay_tv</li>' : '' ?>
                <?= ($listing->ducted_heating != 0) ? '<li>ducted heating</li>' : '' ?>
                <?= ($listing->ducted_cooling != 0) ? '<li>ducted cooling</li>' : '' ?>
                <?= ($listing->splitsystem_heating != 0) ? '<li>splitsystem heating</li>' : '' ?>
                <?= ($listing->hydronic_heating != 0) ? '<li>hydronic heating</li>' : '' ?>
                <?= ($listing->splitsystem_aircon != 0) ? '<li>splitsystem aircon</li>' : '' ?>
                <?= ($listing->gas_heating != 0) ? '<li>gas heating</li>' : '' ?>
                <?= ($listing->reverse_cycle_aircon != 0) ? '<li>reverse cycle aircon</li>' : '' ?>
                <?= ($listing->evaporative_cooling != 0) ? '<li>evaporative cooling</li>' : '' ?>
                <?= ($listing->air_conditioning != 0) ? '<li>air conditioning</li>' : '' ?>
                <?= ($listing->alarm_system != 0) ? '<li>alarm system</li>' : '' ?>
                <?= ($listing->vacuum_system != 0) ? '<li>vacuum system</li>' : '' ?>
                <?= ($listing->pool != 0) ? '<li>pool</li>' : '' ?>
                <?= ($listing->spa != 0) ? '<li>spa</li>' : '' ?>
                <?= ($listing->tennis_court != 0) ? '<li>tennis court</li>' : '' ?>
                <?= ($listing->balcony != 0) ? '<li>balcony</li>' : '' ?>
                <?= ($listing->deck != 0) ? '<li>deck</li>' : '' ?>
                <?= ($listing->courtyard != 0) ? '<li>courtyard</li>' : '' ?>
                <?= ($listing->outdoor_ent != 0) ? '<li>outdoor ent</li>' : '' ?>
                <?= ($listing->shed != 0) ? '<li>shed</li>' : '' ?>
                <?= ($listing->fully_fenced != 0) ? '<li>fully fenced</li>' : '' ?>
                <?= ($listing->open_fire_place != 0) ? '<li>open fire place</li>' : '' ?>
                <?= ($listing->open_spaces != 0) ? '<li>open spaces:' . $listing->open_spaces . ' </li>' : '' ?>
                <?= ($listing->heating_type != '') ? '<li>heating type:' . $listing->heating_type . ' </li>' : '' ?>
                <?= ($listing->hot_water_service != '') ? '<li>hot water service:' . $listing->hot_water_service . '</li>' : '' ?>
                <?= ($listing->inside_spa != 0) ? '<li>inside spa</li>' : '' ?>
                <?= ($listing->outside_spa != 0) ? '<li>outside spa</li>' : '' ?>

                <?= ($listing->other_features != '') ? '<li>other features: ' . $listing->other_features . '</li>' : '' ?>
                <?= ($listing->rural_features_fencing != '') ? '<li>fencing: ' . $listing->rural_features_fencing . '</li>' : '' ?>
                <?= ($listing->rural_features_annual_rainfall != '') ? '<li>annual rainfall: ' . $listing->rural_features_annual_rainfall . '</li>' : '' ?>
                <?= ($listing->rural_features_soiltypes != '') ? '<li>soiltypes: ' . $listing->rural_features_soiltypes . '</li>' : '' ?>
                <?= ($listing->rural_features_improvements != '') ? '<li>improvements: ' . $listing->rural_features_improvements . '</li>' : '' ?>
                <?= ($listing->rural_features_councilrates != '') ? '<li>councilrates: ' . $listing->rural_features_councilrates . '</li>' : '' ?>
                <?= ($listing->rural_features_irrigation != '') ? '<li>irrigation: ' . $listing->rural_features_irrigation . '</li>' : '' ?>
                <?= ($listing->rural_features_carryingcapacity != '') ? '<li>carrying capacity: ' . $listing->rural_features_carryingcapacity . '</li>' : '' ?>
                <?= ($listing->rural_features_services != '') ? '<li>services: ' . $listing->rural_features_services . '</li>' : '' ?>

                <?= ($listing->eco_friendly_solar_panels != 0) ? '<li>solar panels</li>' : '' ?>
                <?= ($listing->eco_friendly_solar_hot_water != 0) ? '<li>solar hot water</li>' : '' ?>
                <?= ($listing->eco_friendly_water_tank != 0) ? '<li>eco friendly water tank</li>' : '' ?>
                <?= ($listing->eco_friendly_grey_water_system != 0) ? '<li>eco friendly grey water system</li>' : '' ?>
                <?= ($listing->idealfor_first_home_buyer != 0) ? '<li>ideal for first home buyer</li>' : '' ?>
                <?= ($listing->idealfor_investors != 0) ? '<li>ideal for investors</li>' : '' ?>
                <?= ($listing->idealfor_downsizing != 0) ? '<li>ideal for downsizing</li>' : '' ?>
                <?= ($listing->idealfor_couples != 0) ? '<li>ideal for couples</li>' : '' ?>
                <?= ($listing->idealfor_students != 0) ? '<li>ideal for students</li>' : '' ?>
                <?= ($listing->idealfor_irg_families != 0) ? '<li>ideal for irg families</li>' : '' ?>
                <?= ($listing->idealfor_reitrees != 0) ? '<li>ideal for reitrees</li>' : '' ?>

                <?= ($listing->views_city != 0) ? '<li>views city</li>' : '' ?>
                <?= ($listing->views_water != 0) ? '<li>views water</li>' : '' ?>
                <?= ($listing->views_valley != 0) ? '<li>views valley</li>' : '' ?>
                <?= ($listing->views_mountain != 0) ? '<li>views mountain</li>' : '' ?>
                <?= ($listing->views_ocean != 0) ? '<li>views ocean</li>' : '' ?>
                <?= ($listing->property_extent != '') ? '<li>property extent:' . $listing->property_extent . '</li>' : '' ?>

                <?= ($listing->car_spaces != 0) ? '<li>car spaces:' . $listing->car_spaces . '</li>' : '' ?>
                <?= ($listing->parking_comments != '') ? '<li>parking comments:' . $listing->parking_comments . '</li>' : '' ?>

            </ul>
        </div>

    </div>
    <div class="contentright">
        <!-- Google map -->
        <div id="map_canvas" style="width:100%; height:240px; margin: 6px 0px 16px 0px;"></div>

        <!-- Open home times -->
        <div id="property-openhomes">
            <h3>Open Homes</h3>
            
            <ul>
               <? if(count($listing->property_inspection_times)> 0): ?>
                <?foreach($listing->property_inspection_times as $pit):?>
                <li>
                    <strong><?=date('l jS F y', strtotime($pit->inspection_date))?></strong>
                    <br/><?=date('h:i A', strtotime($pit->start_time))?> to <?=date('h:i A', strtotime($pit->end_time))?>
                </li>
                <?endforeach;?>
                 <?endif;?>
                <li>
                    <div style="margin:8px 0 0 32px">Contact Agent for private viewing</div>
                </li>
          </ul>
            
        </div>

        <!-- Office info -->
        <div id="property-office">
            <h3>Office details</h3>
            <strong><?= $listing->agentname ?></strong>            
            <?= (isset($listing->agentlocation_addr_street1)) ? '<br/>' . $listing->agentlocation_addr_street1 : '' ?>
            <?= (isset($listing->agentlocation_addr_street2)) ? '<br/>' . $listing->agentlocation_addr_street2 : '' ?>
            <br/><?= $listing->agentlocation_addr_suburb ?> <?= $listing->agentlocation_addr_state ?> <?= $listing->agentlocation_addr_pcode ?> 
              
            <?= (isset($listing->agentphone) && $listing->agentphone!='') ? '<br/><strong>Phone: </strong>' . $listing->agentphone : '' ?>
            <?= (isset($listing->agentfax) && $listing->agentfax!='') ? '<br/><strong>Fax: </strong>' . $listing->agentfax : '' ?>
            
            <h3>Agent details</h3>
            
            <strong><?=(isset($listing->managerfname) && $listing->managerfname !='')?$listing->managerfname.' '.$listing->managerlname:'Agent name'?></strong>
            <?= (isset($listing->managerphone) && $listing->managerphone!='') ? '<br/><strong>Phone: </strong>' . $listing->managerphone : '' ?>
            
            <div style="margin:8px 0">
                <a href="#" onclick="$('#emailagent-dialog-modal').dialog('open');$('#emailagent_id').val('1'); return false;" class="orange-block">
                    Email Agent</a>
            </div>
        </div>

        <!-- Actions: Enquire, Print, Email to Friend -->
        <div id="property-actions">
            <a href="#" onclick="$('#enquirenow-dialog-modal').dialog('open');$('#enquirenow_id').val('1'); return false;" class="orange-block">
                Enquire Now</a>
            <a href="#" onclick="printContent()" class="orange-block">
                Print property details</a>
            <a href="#" onclick="$('#emailfriend-dialog-modal').dialog('open');$('#friend_id').val('1'); return false;" class="orange-block">
                Email to a Friend</a>
        </div>

    </div>
    <div class="clearer"></div>

    <!-- Slideshow Dialog -->
    <div id="slideshow-dialog-modal" class="property-dialog" title="55 Seeana Dve, Mount Cotton">
        <div>
            <ul id="slideshow-carousel" class="jcarousel-skin-tango-slideshow">
                <? if ($showDefalutimage == false): ?>    
                    <? foreach ($listing->property_images as $img): ?>
                        <li><img src="<?= $img->image_url ?>" width="772" height="520px" alt="" /></li>                                                
                    <? endforeach; ?>
                <? endif; ?>
                <? if ($showDefalutimage == true): ?> 
                    <li><img src="<?= base_url() ?>img/noimage.png" width="772" height="520px"  alt="" /></li>
                    <li><img src="<?= base_url() ?>img/noimage.png" width="772" height="520px"  alt="" /></li>
                    <li><img src="<?= base_url() ?>img/noimage.png" width="772" height="520px"  alt="" /></li>
                    <li><img src="<?= base_url() ?>img/noimage.png" width="772" height="520px"  alt="" /></li>
                    <li><img src="<?= base_url() ?>img/noimage.png" width="772" height="520px"  alt="" /></li>                          
                <? endif; ?>               
            </ul>
            <script type="text/javascript">
				
                jQuery(document).ready(function() {
                    jQuery('#slideshow-carousel').jcarousel({
                        scroll: 1,
                        auto: 4,
                        wrap: 'last',
                        initCallback: slideshow_initCallback
                    });
                });
				            
                function slideshow_initCallback(carousel)
                {
                    // Pause autoscrolling if the user moves with the cursor over the clip.
                    carousel.clip.hover(function() {
                        carousel.stopAuto();
                    }, function() {
                        carousel.startAuto();
                    });
                };				            
				
            </script>
        </div>
        <div style="width:100%; text-align:center">(Photo will change every 4 seconds. Mouse over a photo to pause.)</div>
    </div>				
    <script>
        $("#slideshow-dialog-modal").dialog({
            autoOpen: false,
            width: 800,
            height: 600,
            modal: true,
            resizable: false
        });
    </script>

    <!-- Email Agent Dialog -->
    <div id="emailagent-dialog-modal" class="property-dialog" title="Email Agent">
        <div>
            <form id="emailagent">
                <div class="showError"></div>
                <table>
                    <tr>
                        <td style="padding-top:8px">
                            your name *
                        </td>
                        <td style="padding-top:8px">
                            
                            <input id="emailagent_manageremail" name="emailagent_manageremail" type="hidden" value="<?= $listing->manageremail ?>" />
                            <input id="emailagent_emailID" name="emailagent_emailID" type="hidden" value="<?= $listing->agentemail ?>" />
                            <input id="emailagent_name" name="emailagent_name" type="text" value="" style="width:256px"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-top:8px">
                            email address *
                        </td>
                        <td style="padding-top:8px">
                            <input id="emailagent_email"  name="emailagent_email" type="text" value="" style="width:256px"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-top:8px">
                            mobile number
                        </td>
                        <td style="padding-top:8px">
                            <input id="emailagent_mobile"  name="emailagent_mobile" type="text" value="" style="width:256px"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="vertical-align:top; padding-top:8px">
                            message
                        </td>
                        <td style="padding-top:8px">
                            <textarea id="emailagent_message"  name="emailagent_message" style="width:280px; height:96px; resize: none"></textarea>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    <script>
        $("#emailagent-dialog-modal").dialog({
            autoOpen: false,
            width: 420,
            height: 346,
            modal: true,
            resizable: false,
            buttons: {
                Submit: function() {
                    var emailagent_emailID = $('#emailagent_emailID').val();
                    var emailagent_name = $('#emailagent_name').val();
                    var emailagent_email = $('#emailagent_email').val();
                    var emailagent_mobile = $('#emailagent_mobile').val();
                    var emailagent_message = $('#emailagent_message').val();
                    var emailagent_manageremail=$('#emailagent_manageremail').val();
                    
                    if( $.trim(emailagent_name)=="" ){
                        $('#emailagent_name').attr('class','error');
                        $('#emailagent_name').focus();
                        $('#emailagent-dialog-modal  .showError').html('Enter your name');
                        alert('1');
                    } else if( $.trim(emailagent_email)=="" || validateEmail(emailagent_email) == false){
                        $('#emailagent_name').attr('class','required');
                        $('#emailagent_email').attr('class','error');
                        $('#emailagent_email').focus();
                        $('#emailagent-dialog-modal  .showError').html('Enter valid email');
                        alert('2');
                    }else{
                        $('#emailagent_email').attr('class','required');
                        $('#emailagent-dialog-modal  .showError').html('Sending...');
                        $.ajax({  
                            type:"post",
                            data: {emailagent_emailID: emailagent_emailID,emailagent_name:emailagent_name,emailagent_email:emailagent_email,emailagent_mobile:emailagent_mobile,emailagent_message:emailagent_message,emailagent_manageremail:emailagent_manageremail},
                            url:'<?= site_url('property/emailagent') ?>',
                            success: function(data){
                                if(data==1){
                                    //open feedback                                    
                                    $('#emailagent-dialog-modal').dialog("close");
                                    $('#success-dialog-modal .showSuccess').html('Your message has been sent, a Sales Agent will be in contact with you directly.');
                                    $('#success-dialog-modal').dialog('open');
                                }else{
                                    $('#emailagent-dialog-modal').dialog("close");
                                    $('#error-dialog-modal .showError').html('Unable to send mail. Try again later');
                                    $('#error-dialog-modal').dialog('open');
                                }                                   
                                
                
                            } 
                        });                        
                    }
                },
                Cancel: function() {
                    $(this).dialog("close");
                }
            }
        });
    </script>

    <!-- Enquire Now Dialog -->
    <div id="enquirenow-dialog-modal" class="property-dialog" title="Enquire Now">
        <div>
            <form id="eqnuirenow">
                <div class="showError"></div>
                <table>
                    <tr>
                        <td style="padding-top:8px">
                            your name *
                        </td>
                        <td style="padding-top:8px">
                            <input id="eqnuirenow_type" name="proprtyemail_type" type="hidden" value="<?= $type ?>" />
                            <input id="eqnuirenow_manageremail" name="eqnuirenow_manageremail" type="hidden" value="<?= $listing->manageremail ?>" />
                            <input id="eqnuirenow_id" name="eqnuirenow_id" type="hidden" value="<?= $listing->id ?>" style="width:256px"/>
                            <input id="eqnuirenow_name" name="eqnuirenow_name" type="text" value="" style="width:256px"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-top:8px">
                            email address *
                        </td>
                        <td style="padding-top:8px">
                            <input id="eqnuirenow_email"  name="eqnuirenow_email" type="text" value="" style="width:256px"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-top:8px">
                            mobile number
                        </td>
                        <td style="padding-top:8px">
                            <input id="eqnuirenow_mobile"  name="eqnuirenow_mobile" type="text" value="" style="width:256px"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="vertical-align:top; padding-top:8px">
                            message
                        </td>
                        <td style="padding-top:8px">
                            <textarea id="eqnuirenow_message"  name="eqnuirenow_message" style="width:280px; height:90px; resize: none"></textarea>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    <script>
        $("#enquirenow-dialog-modal").dialog({
            autoOpen: false,
            width: 420,
            height: 346,
            modal: true,
            resizable: false,
            buttons: {
                Submit: function() {
                    var eqnuirenow_id = $('#eqnuirenow_id').val();
                    var eqnuirenow_name = $('#eqnuirenow_name').val();
                    var eqnuirenow_email = $('#eqnuirenow_email').val();
                    var eqnuirenow_mobile = $('#eqnuirenow_mobile').val();
                    var eqnuirenow_message = $('#eqnuirenow_message').val();
                    var eqnuirenow_manageremail= $('#eqnuirenow_manageremail').val();
                    var eqnuirenow_type= $('#eqnuirenow_type').val();
                   
                   if( $.trim(eqnuirenow_name)=="" ){
                        $('#eqnuirenow_name').attr('class','error');
                        $('#eqnuirenow_name').focus();
                        $('#enquirenow-dialog-modal  .showError').html('Enter your name');
                    } else if( $.trim(eqnuirenow_email)=="" || validateEmail(eqnuirenow_email) == false){
                        $('#eqnuirenow_name').attr('class','required');
                        $('#eqnuirenow_email').attr('class','error');
                        $('#eqnuirenow_email').focus();
                        $('#enquirenow-dialog-modal  .showError').html('Enter valid email');
                    }else{
                        $('#eqnuirenow_email').attr('class','required');
                        $('#enquirenow-dialog-modal  .showError').html('Sending...');
                        $.ajax({  
                            type:"post",
                            data: {eqnuirenow_id: eqnuirenow_id,eqnuirenow_name:eqnuirenow_name,eqnuirenow_email:eqnuirenow_email,eqnuirenow_mobile:eqnuirenow_mobile,eqnuirenow_message:eqnuirenow_message,eqnuirenow_manageremail:eqnuirenow_manageremail,eqnuirenow_type:eqnuirenow_type},
                            url:'<?= site_url('property/eqnuire') ?>',
                            success: function(data){
                                if(data==1){
                                    //open feedback                                    
                                    $('#enquirenow-dialog-modal').dialog("close");
                                    $('#success-dialog-modal .showSuccess').html('Your enquiry has been sent, a Sales Agent will be in contact with you directly.');
                                    $('#success-dialog-modal').dialog('open');
                                }else{
                                    $('#enquirenow-dialog-modal').dialog("close");
                                    $('#error-dialog-modal .showError').html('Unable to place the enquiry. Try again later');
                                    $('#error-dialog-modal').dialog('open');
                                }                                   
                                
                
                            } 
                        });                        
                    }
                    
                  
                },
                Cancel: function() {
                    $(this).dialog("close");
                }
            }
        });
    </script>

    <!-- Email Friend -->
    <div id="emailfriend-dialog-modal" class="property-dialog" title="Email to a Friend">
        <div>
            <form id="emailfriend">
                <div class="showError"></div>
                <table>
                    <tr>
                        <td style="padding-top:8px">
                            your name *
                        </td>
                        <td style="padding-top:8px">
                            <input id="proprtyemail_type" name="proprtyemail_type" type="hidden" value="<?= $type ?>" />
                            <input id="proprtyemail_id" name="proprtyemail_id" type="hidden" value="<?= $listing->id ?>" />
                            <input id="emailfriend_name"  name="emailfriend_name" type="text" value="" style="width:356px"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-top:8px">
                            your email  *
                        </td>
                        <td style="padding-top:8px">
                            <input id="emailfriend_email"  name="emailfriend_email" type="text" value="" style="width:356px"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-top:8px">
                            friends email *
                        </td>
                        <td style="padding-top:8px">
                            <input id="emailfriend_friendemail"  name="emailfriend_friendemail" type="text" value="" style="width:356px"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="vertical-align:top; padding-top:8px">
                            message
                        </td>
                        <td style="padding-top:8px">
                            <textarea id="emailfriend_message"  name="emailfriend_message" style="width:380px; height:140px; resize: none">Property URL: <?= site_url('property/profile/'.$type."/" . $listing->id) ?></textarea>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    <script>
        $("#emailfriend-dialog-modal").dialog({
            autoOpen: false,
            width: 500,
            height: 408,
            modal: true,
            resizable: false,
            buttons: {
                Submit: function() {
                    var emailfriend_name = $('#emailfriend_name').val();
                    var emailfriend_email = $('#emailfriend_email').val();
                    var emailfriend_friendemail = $('#emailfriend_friendemail').val();
                    var emailfriend_message = $('#emailfriend_message').val();
                    var proprtyemail_id = $('#proprtyemail_id').val();
                    var proprtyemail_type = $('#proprtyemail_type').val();
                    
                    if( $.trim(emailfriend_name)=="" ){
                        $('#emailfriend_name').attr('class','error');
                        $('#emailfriend_name').focus();
                        $('#emailfriend-dialog-modal  .showError').html('Enter your name');
                    } else if( $.trim(emailfriend_email)=="" || validateEmail(emailfriend_email) == false){
                        $('#emailfriend_name').attr('class','required');
                        $('#emailfriend_email').attr('class','error');
                        $('#emailfriend_email').focus();
                        $('#emailfriend-dialog-modal  .showError').html('Enter valid email');
                    }else if($.trim(emailfriend_friendemail)=="" || validateEmail(emailfriend_friendemail) == false){
                        $('#emailfriend_email').attr('class','required');
                        $('#emailfriend_friendemail').attr('class','error');
                        $('#emailfriend_friendemail').focus();
                        $('#emailfriend-dialog-modal .showError').html('Enter valid email');
                    }else{  
                        $('#emailfriend_friendemail').attr('class','required');
                        $('#emailfriend-dialog-modal .showError').html('Sending mail....');
                        $.ajax({  
                            type:"post",
                            data: {emailfriend_name: emailfriend_name,emailfriend_email:emailfriend_email,emailfriend_friendemail:emailfriend_friendemail,emailfriend_message:emailfriend_message,proprtyemail_id:proprtyemail_id,proprtyemail_type:proprtyemail_type},
                            url:'<?= site_url('property/emailtoFriend') ?>',
                            success: function(data){
                                if(data==1){
                                    //open feedback                                    
                                    $('#emailfriend-dialog-modal').dialog("close");
                                    $('#success-dialog-modal .showSuccess').html('Your message has been sent, thank you for sharing this property with your friend.');
                                    $('#success-dialog-modal').dialog('open');
                                }else{
                                    $('#emailfriend-dialog-modal').dialog("close");
                                    $('#error-dialog-modal .showError').html('Unable to send email. Try again later');
                                    $('#error-dialog-modal').dialog('open');
                                }                                   
                                
                
                            } 
                        }); 
                    }
                },
                Cancel: function() {
                    $(this).dialog("close");
                }
            }
        });
    </script>

</div>